//
//  AnimationTimingBootcamp_27.swift
//  SwiftUiExercise
//
//  Created by 徐鹏 on 2023/7/1.
//

import SwiftUI

struct AnimationTimingBootcamp_27: View {
    
    @State var isAnimating: Bool = false
    let timing: Double = 10.0
    
    var body: some View {
        VStack{
            Button("Button") {
                isAnimating.toggle()
            }
            
            RoundedRectangle(cornerRadius: 20)
                .frame(width: isAnimating ? 350 : 50 , height: 100)
                .animation(
                    .spring(
                        response: 3.0,
                        dampingFraction: 0.5,
                        blendDuration: 1.0))
            
            RoundedRectangle(cornerRadius: 20)
                .frame(width: isAnimating ? 350 : 50 , height: 100)
                .animation(Animation.linear(duration: timing))
            
            RoundedRectangle(cornerRadius: 20)
                .frame(width: isAnimating ? 350 : 50 , height: 100)
                .animation(Animation.easeIn(duration: timing))
            
            RoundedRectangle(cornerRadius: 20)
                .frame(width: isAnimating ? 350 : 50 , height: 100)
                .animation(Animation.easeInOut(duration: timing))
            
            RoundedRectangle(cornerRadius: 20)
                .frame(width: isAnimating ? 350 : 50 , height: 100)
                .animation(Animation.easeOut(duration: timing))
        }
    }
}

struct AnimationTimingBootcamp_27_Previews: PreviewProvider {
    static var previews: some View {
        AnimationTimingBootcamp_27()
    }
}
